package bdqn.t09.controller;

import bdqn.t09.pojo.AsRole;
import bdqn.t09.service.AsRoleService;
import com.alibaba.fastjson.JSON;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
public class RoleManagerController {

    @Resource
    private AsRoleService asRoleService;
//    显示角色
    @RequestMapping(value = "roleManagerList",method = RequestMethod.POST)
    @ResponseBody
    public Object asRoleManager(){
        List<AsRole> asRoles = asRoleService.asRoleList();
        return asRoles;
    }
//    添加角色
    @RequestMapping(value = "addRole",method = RequestMethod.POST)
    @ResponseBody
    public Object addRole(AsRole record){
        int count = asRoleService.insert(record);
        return count;
    }

//    修改角色
    @RequestMapping(value = "updateRole",method = RequestMethod.POST)
    @ResponseBody
    public Object updateRole(AsRole record){
        int count = asRoleService.updateByPrimaryKeySelective(record);
        return count;
    }

//    删除角色
    @RequestMapping(value = "deleteRole",method = RequestMethod.POST)
    @ResponseBody
    public Object deleteRole(Long id){
        int count = asRoleService.deleteByPrimaryKey(id);
        return count;
    }

    @RequestMapping(value ={"/ak49"},method = RequestMethod.GET)
    public String roleManager(){
        return  "roleManager";
    }

}
